#ifndef __REACTOR_HPP_
#define __REACTOR_HPP_

#include <iostream>
#define RECV_MAX_SIZE       1024
#define SEND_MAX_SIZE       1024

typedef enum{
            EVENT_I,
            EVENT_R,
            EVENT_W,
            EVENT_A,
        }ITEM_EVENT;

class ITEM {
            public:
                int  item_write(int connfd);
                int  item_conn(int connfd);
                int  item_read(int connfd);
                ITEM_EVENT event;
                std::ostream& operator<<(ITEM);
            private: 
                
                static int recv_cnt;
                static int send_cnt;
                char send_buf[SEND_MAX_SIZE] = {0};
                int send_len = 0;

                char recv_buf[RECV_MAX_SIZE] = {0};
                int recv_len = 0;

                void *argvs;
                
                


        };

class ITEMBLOCKS{
            private:  
                ITEM *items;
                ITEMBLOCKS *next;
                int size;
            public:  
                ITEMBLOCKS(int n);
                ~ITEMBLOCKS();
                ITEMBLOCKS *getnext(void) {return next;};
                ITEM * operator[](int i);
                static int block_num;
        };

class REACTOR{
    public :
        
        REACTOR(int listenfd, int epfd);
        ~REACTOR();
        static void *reactor_thread(void*);
        
        int run();
    private :
        int epfd;
        int listenfd;

        ITEMBLOCKS *itemblocks;
        void *instance;
    protected :
};



#endif //__REACTOR_HPP_
